package com.hmall.search.web;

import com.hmall.search.pojo.ItemDoc;
import com.hmall.search.pojo.PageDTO;
import com.hmall.search.pojo.RequestParams;
import com.hmall.search.service.HmallService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/search")
public class SearchController {
    @Autowired
    private HmallService hmallService;
    @PostMapping("/list")
    public PageDTO<ItemDoc> searchAll(@RequestBody RequestParams params){
        return hmallService.searchAll(params);
    }
    @PostMapping("/filters")
    public Map<String, List<String>> getFilters(@RequestBody RequestParams params){
        return hmallService.getFilters(params);
    }
    @GetMapping("/suggestion")
    public List<String> getSuggestions(@RequestParam("key") String key) {
        return hmallService.getSuggestions(key);
    }
}
